<?php

namespace app\app\controller;

use app\app\model\AppVersionModel;
use app\BaseController;
use app\Request;


class AppVersion extends BaseController
{
    public function check(Request $request)
    {
        $version = input('check_version', '');
        if (empty($version)) {
            return $this->error('缺少参数');
        }
        $res = AppVersionModel::field('version, download_link, remark')->order('version', 'desc')->find();
        if ($res['version'] == $version) {
            $this->success('已是最新版本');
        } else {
            $res['download_link'] = str_replace('\\', '/', $res['download_link']);
            $this->success('更新版本', $res);
        }
    }
}

